#include "tab3dialog.h"
#include "ui_tab3dialog.h"

#include <QSettings>

tab3Dialog::tab3Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::tab3Dialog)
{
    ui->setupUi(this);

    QSettings settings;
    int x_unit = settings.value("chartSetting/x_axis_interval/unit", 0).toInt();
    int x_size = settings.value("chartSetting/x_axis_interval/xsize", 1).toInt();
    int data_size = settings.value("chartSetting/data_size", 20).toInt();

    if(x_unit == 0){
        ui->radioButton->setChecked(true);
        ui->radioButton_2->setChecked(false);
    }else{
        ui->radioButton->setChecked(false);
        ui->radioButton_2->setChecked(true);
    }
    ui->spinBox_4->setValue(x_size);
    ui->spinBox_5->setValue(data_size);

    ui->label_5->setVisible(0);
    ui->spinBox_4->setVisible(0);

}

tab3Dialog::~tab3Dialog()
{
    delete ui;
}

void tab3Dialog::savedata()
{
    QSettings settings;

    int x_unit;
    int x_size = ui->spinBox_4->value();
    int data_size = ui->spinBox_5->value();

    bool r_checked = ui->radioButton->isChecked();
    if(r_checked == true){
        x_unit=0;
    }else{
        x_unit=1;
    }
    settings.setValue("chartSetting/x_axis_interval/unit",x_unit);
    settings.setValue("chartSetting/x_axis_interval/xsize",x_size);
    settings.setValue("chartSetting/data_size",data_size);
}
